// 用户信息 增删改查

import type {User} from '@/types/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore('pk-user', () => {
  
    // 用户信息
    const user = ref<User>()
    // 设置用户 (登陆后 需要用到)
    const setUser = (u:User)=>{
      user.value = u
    }
    // 退出登录  清数据
    const delUser = ()=>{
      user.value = undefined // null
    }

    return { user, setUser, delUser }
  },
  {
    persist: true
  }
)